# print('hello')
#
# print('1234567\t1')
#
#
# print(r'1234567\t1')
#
#
# a=0
# print(not a)
#
# b = True
# print(int(b))
#
# print(4<<2)

list = ["hello", "word", 999, 111]
print(list)
print(id(list))
print(type(list))

print(list.index(999))
print(list[2])

print(type(list[-1]))

# 切片, 获取list中index为 0到2的数据
print(list[:2])

# 1.列表元素的crud
# ---------------添加
list.append("abc")
print(id(list))

# 将集合加入到集合中  ['hello', 'word', 999, 111, 'abc', ['a', 'b']]
l2 = ["a", "b"]
list.append(l2)
print(list)

# 将集合中元素加入到集合中 ['hello', 'word', 999, 111, 'abc', ['a', 'b'], 'a', 'b']
list.extend(l2)
print(list)

# 将任意位置添加元素
list.insert(0, 'hello1')
print(list)

# 在任意位置上添加多个元素 ['hello1', 1, 2, 3, 4]
# 从index为1的元素后整个替换为l3
l3 = [1, 2, 3, 4]
list[1:] = l3
print(list)

# -------------删除
list = ["hello", "word", 999, 111]
# # 将指定元素为word的元素删除，无则报错 ValueError
# list.remove("word")
# print(list)
#
# # pop() 删除index为1的元素
# list.pop(1)
# print(list)

# 切片
lt = list[1:3]
print(lt)

# 删除,直接删了,对象都没了
#
# del list

# 清空集合
list.clear()

print(list)

list = [3, 5, 6, 8, 1]
# list.sort()
# print(list)
# list.sort(reverse=True)
# print(list)

print(sorted(list))
print(sorted(list, reverse=True))

# 列表生成式
ll1 = [i for i in range(1, 10)]
print(ll1)
